<template>
  <div class="div">
    <PageTitle title="审核内容中心"></PageTitle>
    <el-button type="primary" @click="Audit">审核通过</el-button>
    <el-table stripe :data="tableData" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="mobile" label="电话"></el-table-column>
      <el-table-column prop="address" label="地址"></el-table-column>
      <el-table-column prop="taril" label="审核结果">
        <template slot-scope="scope">{{scope.row.taril==1?'审核通过':'未审核'}}</template>
      </el-table-column>
      <el-table-column prop="create_at" label="创建时间"></el-table-column>
      <el-table-column label="操作" width="140">
        <template slot-scope="scope">
          <router-link
            :to="{name: 'CertificationauditDetail', params: {id: scope.row.id}}"
            class="color-theme margin-right"
          >查看</router-link>
          <!--         <el-button type="text" @click="change(scope.row.url,scope.row.id)">修改</el-button>-->
          <!-- <el-button type="text" @click="del(scope.row.id)">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-wrapper">
      <el-pagination
        layout="prev, pager, next"
        @current-change="pageChange"
        :page-size="pageSize"
        :total="totalCount"
        :current-page="pageNum"
      ></el-pagination>
    </div>
    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" />
    </el-dialog>
  </div>
</template>

<script>
import PageTitle from "@/components/pageTitle/PageTitle.vue";
// import _ from 'lodash'
export default {
  name: "GoodsList",
  components: {
    PageTitle
  },
  activated() {
    this._getList();
  },
  data() {
    return {
      tableData: [],
      pageNum: 1,
      totalCount: 0,
      pageSize: 10,
      status: "0", //  筛选参数
      search: "", //搜索参数
      dialogImageUrl: "",
      dialogVisible: false,
      ids:null,
    };
  },
  methods: {
    //多选
    handleSelectionChange(val) {
      console.log("多选---------", val);
      this.ids = val.map(item => {
        return item.id;
      });

      console.log("多选---------", this.ids.join(","));
    },
    //批量审核通过
    Audit(e) {
      console.log("点击了审核通过");
      this.$confirm("确认通过审核？")
        .then(() => {
          console.log("点击了确认");
          this.submitForm()
        })
        .catch(() => {
          console.log("点击了取消");
        });
    },
    // 提交表单
    async submitForm() {
      this.loading = true;
      let data = await this.$axios({
        url: this.$api + "/v1/personal/trial",
        method: "POST",
        data: {
          id: this.ids.join(",")
        }
      });
      this.loading = false;
      if (data.data.code == 0) {
        this.$message({
          message: data.data.data,
          type: "success"
        });
        this._getList()
      }
      console.log("提交审核-------", data);
    },
    //获取列表
    async _getList() {
      let {
        data: { data, code }
      } = await this.$axios({
        url: this.$api + "/v1/personal/details",
        method: "GET",
        params: {
          size: this.pageSize,
          current: this.pageNum,
          state: this.status,
          title: this.search
        }
      });
      if (code == 0) {
        this.tableData = data.items;
        this.totalCount = parseInt(data.page.totalCount);
      }
    },
    goto(id) {
      this.$axios({
        // url: this.$api + '/v1/goods/strike',
        url: this.$api + "/goodsList/detailed/",
        method: "POST",
        data: {
          id
        }
      });
    },
    /* del(id) {
      this.$confirm("确认删除吗？", "提示", {
        type: "warning"
      }).then(() => {
        this._del(id);
      });
    },
    async _del(id) {
      let {
        data: { code, data }
      } = await this.$axios({
        // url: this.$api + '/v1/goods/strike',
        url: this.$api + "/v1/personal/strike",
        method: "POST",
        data: {
          id
        }
      });
      if (code == 0) {
        this.$message.success(data);
        this._getList();
      }
    }, */
    // handleSearch() {
    //   this.pageNum = 1
    //   this._getList()
    // },
    pageChange(pageNum) {
      this.pageNum = pageNum;
      this._getList();
    },
    handlePictureCardPreview(src) {
      this.dialogImageUrl = src;
      this.dialogVisible = true;
    }
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/css/select-bar.scss";
video {
  width: 100px;
  height: 60px;
  cursor: pointer;
}
.list-img {
  width: 100px;
  height: auto;
}
.el-button--text {
  text-decoration: none;
}
</style>